<template>
	<om-formsub-outer :index="index">
		<om-autoform ref="autoform" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {subOnLoad, changeEditor,configSelectData} from '../../../static/js/formUtil.js';
	import { ignoreHtml,ptFloat,minusF,getDateStr} from '@/static/js/common.js';
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return {
				initValue:{
				},
				autoformdata: [],
				cachename:'',
				index:null,
				datas:[],
				order:0,
				formdata:{},
				businessCacheKey:"hr-u-confirm-data-info-workExp-business-cache"
			}
		},
		methods: {
			verifyMajorYearW(val){
				let _that = this
				if(val.toString().indexOf(".") != -1  && val.toString().split(".")[1].length>1){
					  _that.$refs.autoform.formdata.majorYearW = Number(val).toFixed(1)
				}
			},
			initLoad(){
				let _that = this
				changeEditor(_that.autoformdata[0].editors, "startDateW","endField","endDateW")
				changeEditor(_that.autoformdata[0].editors, "endDateW","startField","startDateW")	
				changeEditor(_that.autoformdata[0].editors, "dutyW", "linkParam",{
					other: JSON.stringify({
						code:"38697"
					}),
					namefield:"dicname",
					initload:true,
					url:"tsysdict/getListByCode",
					cachename:_that.businessCacheKey
				})
			}
		},
		onLoad(e){
			let _that = this
			subOnLoad(_that, e, function() {
				if(e.configDataCacheKey){
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							//if(res.data && res.data instanceof Array){
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
								Object.assign(_that.initValue, _that.formdata)
								_that.autoformdata[0].order = _that.order
								_that.initLoad()
							}
						}
					});
				}
			})
		},
		onShow() {
			let _that = this
			if(_that.$refs.autoform){
				uni.getStorage({
					key: this.businessCacheKey,
					success: function(res) {
						if(res.data){
							let d = res.data
							var formdata  = _that.$refs.autoform.formdata
							if(Object.prototype.toString.call(d) != "[object Object]"){
								formdata.dutyW = d
							}else{
								formdata.dutyW = d.dicname
							}
							uni.removeStorage({
								key: _that.businessCacheKey
							});
						}
					}
				});
			}
		}
	}
</script>

<style>

</style>
